package com.yohann.designPattern.factory.factoryMethod.factory;

import com.yohann.designPattern.factory.simpleFactory.pizza.Pizza;

import java.util.Scanner;

/**
 * <p>
 * 基础工厂
 * </p>
 *
 * @author Yohann
 * @since 2021/2/1 20:51
 */
public abstract class BaseFactory {
    private final Scanner scanner = new Scanner(System.in);

    abstract Pizza createPizza(String type);

    public BaseFactory() {
        do {
            String type = scanner.nextLine();
            Pizza pizza = createPizza(type);

            if (pizza != null) {
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            }
        } while (true);
    }
}